﻿package com.gengine.utils
{
    import flash.geom.*;

    public class MathUitl extends Object
    {
        public static const ONE_RADIANS:Number = 57.2958;
        public static const ONE_ANGLE:Number = 0.0174533;
        private static const MAX_RATIO:Number = 2.32831e-010;
        private static var r:uint;

        public function MathUitl()
        {
            return;
        }// end function

        public static function getRadiansByPoint(param1:Point, param2:Point) : Number
        {
            return Math.atan2(param2.y - param1.y, param2.x - param1.x);
        }// end function

        public static function getRadiansByXY(param1:Number, param2:Number, param3:Number, param4:Number) : Number
        {
            return Math.atan2(param4 - param2, param3 - param1);
        }// end function

        public static function getAngleByXY(param1:Number, param2:Number, param3:Number, param4:Number) : Number
        {
            return getRadiansByXY(param1, param2, param3, param4) * ONE_RADIANS;
        }// end function

        public static function getRadians(param1:Number) : Number
        {
            return param1 * ONE_ANGLE;
        }// end function

        public static function getAngle(param1:Number) : Number
        {
            return param1 * ONE_RADIANS;
        }// end function

        public static function getDistance(param1:Number, param2:Number, param3:Number, param4:Number) : Number
        {
            var _loc_5:* = param2 - param1;
            var _loc_6:* = param4 - param3;
            return Math.sqrt(_loc_5 * _loc_5 + _loc_6 * _loc_6);
        }// end function

        public static function random(param1:int, param2:int) : int
        {
            var _loc_3:* = param2 - param1;
            return Math.floor(Math.random() * (_loc_3 + 1)) + param1;
        }// end function

        public static function setSeed(param1:uint) : void
        {
            r = param1;
            return;
        }// end function

        public static function getNext() : Number
        {
            r = r ^ r << 21;
            r = r ^ r >>> 35;
            r = r ^ r << 4;
            return r * MAX_RATIO;
        }// end function

        public static function getSign(param1:Number) : int
        {
            if (param1 > 0)
            {
                return 1;
            }
            if (param1 < 0)
            {
                return -1;
            }
            return 0;
        }// end function

    }
}
